function checkAnswer(inputId, correctAnswer) {
  const userAnswer = document.getElementById(inputId).value.trim();
  const hints = document.querySelectorAll(`#${inputId} ~ .hint`);
  
  if (userAnswer === correctAnswer) {
    alert('回答正确!');
    nextQuestion(inputId);
  } else {
    let hintShown = false;
    for (let hint of hints) {
      if (!hintShown) {
        hint.style.display = 'block';
        hintShown = true;
      }
    }
  }
}

function showAnswer(inputId, correctAnswer) {
  document.getElementById(inputId).value = correctAnswer;
}

function nextQuestion(inputId) {
  const question = document.getElementById(inputId).parentElement;
  question.style.display = 'none'; // Hide current question
  const nextQuestion = question.nextElementSibling;
  if (nextQuestion) {
    nextQuestion.style.display = 'block'; // Show next question
  } else {
    document.getElementById('result').style.display = 'block'; // Show result message
  }
}
